package com.umeox.watch.moto.alarm.base;

import android.annotation.SuppressLint;
import android.app.Application;
import android.content.Intent;

import com.umeox.moto.common.log.Logger;
import com.umeox.watch.moto.alarm.R;
import com.umeox.watch.moto.dataservice.DataProvider;
import com.umeox.watch.moto.dataservice.constants.Constants;

import uk.co.chrisjenx.calligraphy.CalligraphyConfig;

public class BaseApp extends Application {

    private static BaseApp instance;

    public static BaseApp getInstance() {
        return instance;
    }

    @SuppressLint("WrongConstant")
    public void scheduleAlarm() {
        Logger.i("发送广播重置闹钟");
        Intent intent = new Intent(Constants.ACTION_UPDATED_ALARMLIST);
        intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES | Intent.FLAG_RECEIVER_FOREGROUND | Constants.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        instance.sendBroadcast(intent);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        DataProvider.initialize(this);
        scheduleAlarm();


        CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                .setDefaultFontPath("fonts/Roboto-Medium.ttf")
                .setFontAttrId(R.attr.fontPath)
                .build()
        );
    }


}
